// 1 导入模块
const fs = require('fs')
// 2. 封装一个函数
function ReadFileFn(path) {
    return new Promise((resolve, reject) => {
        // 异步任务
        fs.readFile(path, (err, reason) => {
            if (err) {
                reject(err)
            } else {
                resolve(reason)
            }
        })
    })
}
// 3. 调用
ReadFileFn('./resource/1.txt').then(value => {
    console.log(value.toString())
}, reason => {
    console.log(reason)
})